home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
asm
/
alib11b.zip
/
CODE1.ZIP
/
DISPINFO
/
DISPINFO.ASM
Wrap
Assembly Source File
|
1994-10-06
|
9KB
|
391 lines
page 66,132
comment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( SYSTEM )
CHECK_ANSI - check if ANSI active
;
; inputs: none
;
; output: CF = 1 if no ANSI driver active
; CF = 0 if ANSI active
;* * * * * * * * * * * * * *
public CHECK_ANSI
CHECK_ANSI PROC FAR
APUSH AX,DX,DS
MOV AX,CS
MOV DS,AX
CALL console_input
CALL CHECK_ANSI_cont1
DB 1BH,'[6n$'
;
CHECK_ANSI_cont1:
POP DX
CALL console_output
MOV AH,0Bh ;check STDIN status, al=ff if input
INT 21h
CMP AL,0FFh
JZ IA_1 ;jmp if char. is ready from ansi call
CALL isansi_cont2
db 0dH,' ',0dH,'$'
isansi_cont2:
POP DX
CALL console_output
STC
JMP IA_2
IA_1:
CALL console_input
CLC
IA_2:
APOP DS,DX,AX
JB NO_ANSI
CLC
RETF
NO_ANSI:
STC
RETF
CHECK_ANSI ENDP
;------------------------------
console_output:
MOV AH,09
INT 21h
RET
console_input:
MOV AH,06
MOV DL,0FFh
INT 21h
JNZ console_input
RET
comment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( SYSTEM )
DISPLAY_INFO - determine display information
;
; inputs: none
;
; output: AL = screen rows
; CH = screen columns
; BX:[SI] = video buffer address
; register DX is modified
;* * * * * * * * * * * * * *
public display_info
display_info:
push es
call detectvid ;get video type
cmp ax,0
je display_info_exit ;exit if no display
;
; check for special case, dual display and alternate monochrome active
;
mov bx,0
mov es,bx
cmp al,3 ;check if color display
jb mono_port ;jmp if mono
cmp word ptr es:[463h],3d4h ;verify color port active
je port_ck_end ;jmp if port ok
mov ax,2 ;force monochrome display
jmp port_ck_end
mono_port:
cmp word ptr es:[463h],3b4h ;verify mono port active
je port_ck_end
mov ax,5 ;force cga color
port_ck_end:
push ax
mov ax,0500h
int 10h ;force page 0
mov ax,0
mov es,ax
mov bh,es:[449h] ;get display mode
pop ax
cmp al,6
jbe get_rows ;jmp if mono or cga
cmp al,9
je get_rows ;jmp if cga compatable
push ax
push bx
mov ax,1130h
mov bh,0
push es
int 10h
pop es
pop bx
pop ax
mov bl,dl ;move rows to -bl-
jmp rows_ok
get_rows:
mov bl,es:[484h] ;get rows
cmp bl,0
je fix_rows ;jmp if row info bad
cmp bl,80
jb rows_ok ;jmp if row info found
fix_rows:
mov bl,24 ;force 25 lines on screen
rows_ok:
inc bl
get_columns:
mov cx,word ptr es:[44ah] ;get columns on display
display_info_exit:
pop es
ret
comment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( SYSTEM )
DETECTVID - determine display type
;
; inputs: none
;
; outputs: ax = 0 no display
; 1 monochrome
; 2 hercules
; 3 cga digital (mono)
; 4 cga analog (mono)
; 5 cga analog (color)
; 6 ega mono
; 7 ega color 64k
; 8 ega color 64k+
; 9 cga compatable
; 10 vga mono
; 11 vga color
;* * * * * * * * * * * * * *
vga_mono equ 10
vga_color equ 11
monochrome equ 1
hercules equ 2
public detectvid
detectvid:
mov ax,1a00h ;used by mcga and vga
int 10h
cmp al,1ah ;if al = 1ah then mcga or vga is present
jnz dt1
cmp bl,7 ;if active monitor is monochrome vga
jnz do1
mov ax,vga_mono ;mono vga found
ret
do1:
cmp bl,8 ;if active monitor is color vga
jnz do2
mov ax,vga_color ;color vga found
ret
do2:
cmp bl,0ah ;if digital mcga
jnz do3
mov ax,3 ;digital mcga found
ret
do3:
cmp bl,0bh ;if monochrome mcga
jnz do4
mov ax,4 ;analog monochrome mcga found
ret
do4:
cmp bl,0ch ;if color mcga
jnz dt1
mov ax,5 ;analog color mcga found
ret
dt1:
mov ah,12h ;used by ega
mov bl,10h
int 10h
cmp bl,10h ;if bl is not 10h then ega is present
jz dt2
cmp bh,1 ;if monochrome ega
jnz do5
mov ax,6 ;monochrome ega
ret
do5:
or bl,bl ;or 64k ega board
jnz do6
mov ax,7 ;color ega with 64k memory
ret
do6:
mov ax,8 ;color ega with > 64k memory
ret
dt2:
mov dx,3d4h ;address for cga crtc
call find6845 ;look for controller
jnc dt3 ;if clear then cga present
mov dx,3b4h ;address for hercules or mda
call find6845 ;look for controller
jnc dt4 ;jump if hercules or mda present
mov ax,0 ;unable to detect card
ret
dt3:
mov ax,9 ;cga compatible present
ret
dt4:
mov dl,0bah ;read this port
in al,dx
and al,80h ;get value in ah
mov ah,al
mov cx,8000h ;loop this many times
dt5:
in al,dx ;read port
and al,80h
cmp ah,al ;has value changed
loopz dt5
jcxz dt6 ;if cx = 0 then mda is present
mov ax,hercules ;hercules card
ret
dt6:
mov ax,monochrome ;mda card
ret
;-------------------------------------------------------------------------
public find6845
find6845 proc near ;find out if crtc is present
mov al,0fh ;select reg ( cursor low )
out dx,al
inc dx
in al,dx ;al = cursor low position
mov ah,al ;save value in ah
mov al,66h ;arbitrary value
out dx,al ;write to crtc
mov cx,100h
f61:
loop f61 ;wait for response
in al,dx
xchg ah,al ;ah = returned value
out dx,al ;reset port
cmp ah,66h ;was value unchanged
je f62
stc ;if no response
f62:
ret
find6845 endp
comment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( SYSTEM )
FIND_DISPLAY_SEGMENT - scan for current display buffer segment
;
; inputs: display mode 3 or 7 must be set and display page must = 0
;
; output: display_segment is set
;
;* * * * * * * * * * * * * *
public find_display_segment
find_display_segment:
push ax
push bx
push es
cli
mov ax,0b000h ;display seg?
mov es,ax
mov bx,es:[0] ;save current data
mov word ptr es:[0],0101h ;store code 0101 at b000
mov ax,0b800h ;move to b800
mov es,ax
mov cx,es:[0] ;save current data
mov word ptr es:[0],0303h ;store code 0303 at b800
push bx
push cx
mov ah,3
mov bh,0
int 10h ;read cursor position -> dx
mov cx,dx ;save cursor posn
mov ah,2 ;move
mov bh,0 ; cursor
mov dx,0 ; to page 0
int 10h ; top left
mov ah,8 ;read
mov bh,0 ; data
int 10h ; at cursor
;
; restore cursor position
;
push ax ;save data read
mov dx,cx
mov ah,2
int 10h
pop ax ;restore data read
;
; restore origional display buffer data
;
pop cx ; origional
pop bx ; display contents
push ax ;save data read
mov ax,0b000h
mov es,ax
mov word ptr es:[0],bx
mov ax,0b800h
mov es,ax
mov word ptr es:[0],cx
;
; recover data read from display to determine segment location
;
pop ax
cmp ax,0101h
je use_b000
use_b800:
mov ax,0b800h
jmp set_seg_cont
use_b000:
mov ax,0b000h
set_seg_cont:
mov lib_info.crt_seg,ax
sti
pop es
pop bx
pop ax
ret
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; set_display_flags - determine cga snow flag and mono flag default settings
; inputs: crt_info data stored in data base
; output: al = mono flag (1=mono)
; dx = snow flag (cga port if cga)
;
set_display_flags:
sub ax,ax
mov es,ax
;
; get display mode
;
mov al,byte ptr es:[449h] ;get display mode
mov lib_info.crt_mode,al
;
; force display page zero
;
mov ah,5
mov al,0 ;page 0
int 10h
;
; set cga flag
;
mov al,lib_info.crt_type
cmp al,3
jb mono_display
cmp al,5
jbe cga_display
cmp al,9
je cga_display
;
; we must have a color display, it is not a cga or mono
;
mov al,0
mov dx,0
jmp sdf_exit
;
mono_display:
mov al,1
mov dx,0
jmp sdf_exit
cga_display:
mov al,0
mov dx,3dah
sdf_exit:
ret